<template>
  <div>
    <BasicTable @register="registerTable">
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              label: '删除',
              color: 'error',
              popConfirm: {
                title: '是否确认删除',
                confirm: handleDelete.bind(null, record),
              },
            },
          ]"
        />
      </template>
    </BasicTable>
  </div>
</template>

<script lang="ts">
  import { BasicTable, TableAction, useTable } from '/@/components/Table';
  import { defineComponent } from 'vue';
  import { columns, dataSource, searchFormSchema } from './comment.data';

  export default defineComponent({
    components: {
      BasicTable,
      TableAction,
    },
    setup() {
      const [registerTable, { reload }] = useTable({
        // api: queryList,
        dataSource,
        useSearchForm: true,
        formConfig: {
          labelWidth: 80,
          schemas: searchFormSchema,
          showResetButton: false,
        },
        pagination: false,
        scroll: { y: 400 },
        columns: columns,
        clickToRowSelect: false,
      });

      // 单个删除
      const handleDelete = (record) => {
        console.log(record);
        reload();
      };

      return {
        registerTable,
        handleDelete,
      };
    },
  });
</script>

<style scoped lang="less"></style>
